<?php

/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

namespace EasyActionPHP\Forms;

 /**
  * @author Flavio de Vasconcellos Correa
  * @since 2008/05/30
  * @package EasyActionPHP
  * @subpackage Forms
  * @version $id$
  */
class ActionFormBean {

    private $name;
    private $properties;

    public function __construct($name) {
        $this->name = $name;
    }

    public function addProperty($name, $type, $size = 0, $required = false) {
        $this->properties[$name]['name'] = $name;
        $this->properties[$name]['type'] = $type;
        $this->properties[$name]['size'] = $size;
        $this->properties[$name]['required'] = $required;
    }

    public function getProperties() {
        return $this->properties;
    }

}

class ActionFormMapping {

    static $instance;
    private $uriBuffer;

    private function __construct() {
        $this->uriBuffer = Array();
    }

    public function getInstance() {
        if (!isset(self::$instance)) {
            self::$instance = new \EasyActionPHP\Forms\ActionFormMapping();
        }
        return self::$instance;
    }

    public function register($uri) {
        $instance = self::getInstance();
        try {
            if (file_exists($uri)) {
                $instance->uriBuffer[] = $uri;
            } else {
                throw new \Exception("CRITICAL:'$uri' Form Mapping File not found. Your webmaster are notified!");
            }
        } catch (Exception $e) {
            throw ($e);
        }
    }

}

?>
